//
//  HeadViewTwo.m
//  ProjectA_LK
//
//  Created by 萌萌的小坤坤 on 16/6/15.
//  Copyright © 2016年 冷坤. All rights reserved.
//

#import "HeadViewTwo.h"
#import "HeadCollectionViewTwo.h"
@implementation HeadViewTwo

- (instancetype)initWithFrame:(CGRect)frame 
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatCollectionView:frame];
    }
    return self;
}

- (void)creatCollectionView:(CGRect)frame
{
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(frame.size.width / 4 - 0.25, frame.size.height);
    flowLayout.minimumInteritemSpacing = 0;
    flowLayout.minimumLineSpacing = 0;
    flowLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    
    self.colletionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height) collectionViewLayout:flowLayout];
    self.colletionView.dataSource = self;
    self.colletionView.delegate = self;
    self.colletionView.backgroundColor = [UIColor whiteColor];
    [self addSubview:_colletionView];
    
    [self.colletionView registerClass:[HeadCollectionViewTwo class] forCellWithReuseIdentifier:@"headCollectionViewTwo"];
    
    [_colletionView release];
    
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.dataSource.hot.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    HeadCollectionViewTwo *item = [collectionView dequeueReusableCellWithReuseIdentifier:@"headCollectionViewTwo" forIndexPath:indexPath];
    item.models = self.dataSource.hot[indexPath.item];
    return item;
}



@end
